<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/jsp/declare.jsp" %>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath %>" />
	<%-- <meta http-equiv="refresh" content="0; url=<%=basePath %>mvc/renter/communityList.htm?fromUserName=${param.fromUserName }" /> --%>
	<title>信息-房客</title>
	<%@ include file="/common/jsp/common.jsp" %>

	<script>
	function delCRegister() {
		jConfirm("确认重绑便签？", function(yes){
			if (!yes)
				return;

// 			doAjax({
// 				url: addFromUserName("mvc/renter/delCRegister.json"),
// 				data: {
// 					phone: "${renterInfo.phone }",
// 					idcard: "${renterInfo.idcard }",
// 					enote: "${renterInfo.enote }"
// 				},
// 				async: false,
// 				success: function(json){
// 					if (json && json.msg)
// 						jAlert(json.msg);

// 					if (json && json.flag == "0") {
						$("._show").hide();
						$("._edit").show();
// 					}
// 				}
// 			});
		});
	}
	
	function ChongXinXiaFa() {
		var enote = "${renterInfo.enote}";
		if (!enote) {
			jAlert("电子便签码不可以为空");
			return;
		}
		doAjax({
			url: addFromUserName("mvc/renter/wxKUpStatus.json"),
			data: {
				phone: "${renterInfo.phone }",
				idcard: "${renterInfo.idcard }",
				enote: "${renterInfo.enote }"
			},
			async: false,
			success: function(json){
				if (json && json.msg){
					jAlert(json.msg);
				}
			}
		});
		
	}
	function validateEnote() {
		var newEnote = $("#newEnote").val();
		if (!newEnote) {
			jAlert("电子便签不能为空");
			return false;
		}
		return true;
	}
	</script>
</head>
<body class="frame bgcolor">
	<div class="center">
		<div class="logo">
			<img src="aizu/images/logo.jpg" />
		</div>
		<h1 class="name">房客信息</h1>

		<div class="row">
			<div id="userName" placeholder="姓名" class="input">${renterInfo.namel }</div>
		</div>
		<div class="row">
			<div id="userPhone" placeholder="手机号" class="input">${renterInfo.phoneHidden }</div>
		</div>
		<div class="row">
			<div id="userPhone" placeholder="身份证" class="input">${renterInfo.idcardHidden }</div>
		</div>
		<div class="row _show">
			<div placeholder="电子便签" class="input" id="oldCode">${renterInfo.enote }</div>
		</div>
		<div class="row _show">
			<input type="button" value="重绑便签" class="register" onclick="delCRegister()" />
		</div>

		<form action="mvc/renter/reRegister.htm" method="post" class="form" onsubmit="return validateEnote();">
			<input type="hidden" name="fromUserName" value="${param.fromUserName }" />
			<input type="hidden" name="nameL" value="${renterInfo.namel }" />
			<input type="hidden" name="phone" value="${renterInfo.phone }" />
			<input type="hidden" name="idcard" value="${renterInfo.idcard }" />
			<input type="hidden" name="enote" value="${renterInfo.enote }" />
			<div class="row _edit" style="display: none;">
				<input type="text" id="newEnote" name="newEnote" value="${renterInfo.enote }" placeholder="请输入电子便签" maxlength="50" class="input" />
			</div>
			<div class="row _edit" style="display: none;">
				<input type="submit" value="确认电子标签" class="register" />
			</div>
		</form>

		<div class="row">
			<input type="button" value="重新下发" class="register" onclick="ChongXinXiaFa()" />
		</div>
		<div class="row">
			<input type="button" value="返回首页" class="register" onclick="WeixinJSBridge.call('closeWindow');" />
		</div>
	</div>
</body>
</html>
